/**
 * Copyright 2014,Peak Tai 台俊峰(taijunfeng_it@sina.com).
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * 		http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.cenluan.login;

import com.cenluan.common.Const;
import com.cenluan.user.User;
import com.jfinal.core.Controller;

/**
 * 登录
 * 
 * @author peak
 * 
 */
@ClearLoginInterceptor
public class LoginController extends Controller {
	/**
	 * 登录页
	 */
	public void index() {
		if (!isParaBlank("to")) {
			setSessionAttr(Const.SESSION_REFERER, getPara("to"));
		}

	}

	/**
	 * 登出
	 */
	public void logout() {
		getSession().invalidate();
		redirect("/");
	}

	/**
	 * 本地登录，由于项目是完全第三方登录的，所以本地无法登录<br>
	 * 这个方法虚拟一个user对象，放入session算是登录了，程序部署时切记要把这个方法注释了
	 */
	public void local() {
		setSessionAttr(Const.SESSION_USER, User.dao.findById("XXXX"));
		redirect("/");
	}
}
